package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderStatisticsVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    //新增订单
    void insert(Orders orders);

    /**
     * 根据订单号查询订单
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    //历史订单查询
    Page<Orders> historyOrders(OrdersPageQueryDTO ordersPageQueryDTO);


    //根据订单id查询订单信息
    @Select("select * from orders where id=#{id}")
    Orders getById(Long id);

    //各个订单状态搜索
    Integer orderStatistics(Integer status);

    //超时未支付订单
    @Select("select * from orders where status=#{status} and order_time<#{time}")
    List<Orders> processOrder(Integer status, LocalDateTime time);

    //营业额统计
    Double turnoverStatistics(LocalDateTime begin,LocalDateTime end);

    //订单统计
    Integer ordersStatistics(Map orderMap);
}
